<template>
	<!-- 部门管理 -->
	<view>
		<view class="boxtop">
			<text class="text">{{title}}</text>
		</view>
		<view class="boxhead">
			<view class="news_item" v-for="(item,index) in list" :key="index">
				<image class="img1" :src="item.dptimg"></image>
				<view class="right">
					<view class="tit">
						<text>{{item.dptname}}</text>
					</view>
					<hr>
					<view class="info">
						<text>负责人id:{{item.dptemid}}</text>
					</view>
				</view>
				<button class="btnimg" @click="search(index)">
					<image class="img2" src="../../../static/paimg/right-arrow.png"></image>
				</button>
			</view>
		</view>
		<view>
			<drag-button name="新增" :isDock="true" :existTabBar="true" @btnClick="btnClick" />
		</view>
	</view>
</template>

<script>
	import dragButton from '../../../components/drag-button.vue';
	export default {
		data() {
			return {
				title:'部门管理',data:'',
				list:[]
			}
		},
		components: {
			dragButton
		},
		onLoad() {
			this.getdata();
		},
		methods: {
			async getdata(){
				const res =await this.Request({
					url:'/api/department/getdptdata'
				})
				this.list = res.data
				this.data = res
			},
			search(e){
				var item = JSON.stringify(this.data.data[e]);
				uni.navigateTo({
					url:'/pages/super/superpage/dptpage?item=' + item
				})
			},
			btnClick(){
				setTimeout(() => {
					uni.navigateTo({
						url:'/pages/super/superpage/dptadd'
					})
				},300)
			}
		}
	}
</script>

<style lang="scss">
	.boxtop{
		width: 100%;
		background-color: #efefef;
		display: flex;
		border-bottom: 1px solid #ccc;
		.text{
			margin: 5px 0 5px 5px;
			font-size: 110%;
			font-weight: 700;
			color: #d3d3d3;
		}
	}
	.boxhead{
		.news_item{
			height: 80px;
			width: 100%;
			border: 2px solid #ccc;
			display: flex;
			.img1{
				margin: auto;
				margin-left: 40px;
				width: 40px;
				height: 40px;
			}
			.btnimg{
				display: flex;
				opacity: 0.4;
				.img2{
					margin: auto;
					margin-left: 30px;
					width: 30px;
					height: 30px;
				}
			}
			.right{
				width: 180px;
				border-left: 2px solid #ccc;
				margin-left: 40px;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.tit{
					font-size: 16px;
					font-weight: 600;
					margin-left:15px;					
					margin-top: 12px;
				}
				.info{
					font-size: 13px;
					margin-left:15px;
					margin-bottom: 10px;
				}
			}
		}
	}
</style>
